using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class Vw_album_list {
		#region Fields
		private DateTime keyin_date = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private int owner_id;
		private int album_id;
		private string album_name;
		private int pic_cont;
		private string default_pic;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the Vw_album_list class.
		/// </summary>
		public Vw_album_list() {
		}
		
		/// <summary>
		/// Initializes a new instance of the Vw_album_list class.
		/// </summary>
		public Vw_album_list(DateTime keyin_date, int owner_id, int album_id, string album_name, int pic_cont, string default_pic) {
			this.keyin_date = keyin_date;
			this.owner_id = owner_id;
			this.album_id = album_id;
			this.album_name = album_name;
			this.pic_cont = pic_cont;
			this.default_pic = default_pic;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the Keyin_date value.
		/// </summary>
		public DateTime Keyin_date {
			get { return keyin_date; }
			set { keyin_date = value; }
		}
		
		/// <summary>
		/// Gets or sets the Owner_id value.
		/// </summary>
		public int Owner_id {
			get { return owner_id; }
			set { owner_id = value; }
		}
		
		/// <summary>
		/// Gets or sets the Album_id value.
		/// </summary>
		public int Album_id {
			get { return album_id; }
			set { album_id = value; }
		}
		
		/// <summary>
		/// Gets or sets the Album_name value.
		/// </summary>
		public string Album_name {
			get { return album_name; }
			set { album_name = value; }
		}
		
		/// <summary>
		/// Gets or sets the Pic_cont value.
		/// </summary>
		public int Pic_cont {
			get { return pic_cont; }
			set { pic_cont = value; }
		}
		
		/// <summary>
		/// Gets or sets the Default_pic value.
		/// </summary>
		public string Default_pic {
			get { return default_pic; }
			set { default_pic = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the vw_album_list table.
		/// </summary>
		public void Insert() {
			SqlClientUtility.ExecuteNonQuery("vw_album_listInsert", keyin_date, owner_id, album_id, album_name, pic_cont, default_pic);
		}
		
		/// <summary>
		/// Selects all records from the vw_album_list table.
		/// </summary>
		public static List<Vw_album_list> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("vw_album_listSelectAll")) {
				List<Vw_album_list> vw_album_listList = new List<Vw_album_list>();
				while (dataReader.Read()) {
					Vw_album_list vw_album_list = MakeVw_album_list(dataReader);
					vw_album_listList.Add(vw_album_list);
				}
				return vw_album_listList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the vw_album_list class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static Vw_album_list MakeVw_album_list(SqlDataReader dataReader) {
			Vw_album_list vw_album_list = new Vw_album_list();
			
			if (dataReader.IsDBNull(0) == false) {
				vw_album_list.Keyin_date = dataReader.GetDateTime(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				vw_album_list.Owner_id = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				vw_album_list.Album_id = dataReader.GetInt32(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				vw_album_list.Album_name = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				vw_album_list.Pic_cont = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				vw_album_list.Default_pic = dataReader.GetString(5);
			}

			return vw_album_list;
		}
		#endregion
	}
}
